package com.example.yunbiji0314.util;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts;

public class JwtJieXi {
    public static void main(String[] args) {
        String ss="eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDMwNDY2NjAsImlhdCI6MTc0Mjk2MDI2MCwiYWdlIjoxOCwidXNlcm5hbWUiOiJhZG1pbiJ9.J_PNZUmcHXnI0TYiSse7_IVxDfbhsn839MUNU8qTYK0";

        // 设置密钥
        JwtParser hxzy = Jwts.parser().setSigningKey("hxzy");
        // 将jwt的第二部分解析出来
        Jws<Claims> claimsJws = hxzy.parseClaimsJws(ss);
        Claims body = claimsJws.getBody();
        System.out.println(body);
        System.out.println(body.get("username"));
        System.out.println(body.get("age"));
    }
}
